<%@page import="org.lxy.domain.InfomationEntity"%>
<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" />
<title>Edit</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="Stylesheet" href="/css/Form.css" />
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/js/kindeditor/kindeditor-all.js"></script>
<script type="text/javascript" src="/js/kindeditor/lang/zh-CN.js"></script>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-weight: bold;
}

.td_right {
	text-align: right;
}
</style>
<script>
	var editor;
	$(function() {
		editor = KindEditor.create('#neirong', {
			allowFileManager : true,
			resizeType : 1,
			minWidth : 500,
			minHeight : 210,
			items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print',
					'template', 'cut', 'copy', 'paste', '|', 'justifyleft',
					'justifycenter', 'justifyright', '|', 'insertorderedlist',
					'insertunorderedlist', 'clearhtml', 'quickformat', '|',
					'anchor', 'link', 'unlink', '|', 'fullscreen', '/',
					'formatblock', 'fontname', 'fontsize', '|', 'forecolor',
					'hilitecolor', 'bold', 'italic', 'underline', 'lineheight',
					'removeformat', '|', 'image', 'multiimage', 'flash',
					'media', 'insertfile', '|', 'table', 'hr', 'emoticons',
					'baidumap' ],
			fileManagerJson : 'js/kindeditor/jsp/file_manager_json.jsp',
			//这里是指定的文件上传input的的属性名
			//filePostName: "uploadFile",
			//这里就是指定文件上传的请求地址，上面也已经说了，upload_json.jsp就相当去一个servlet去进行保存文件，这个地方很重要
			uploadJson : 'js/kindeditor/jsp/upload_json.jsp',
			resizeType : 1,
			allowPreviewEmoticons : true,
			allowImageUpload : true,
		});
	});

	function upload() {

		$("#PicLoad").click();
	}
	function change(file) {
		// var prevDiv = document.getEleme+ntById('img');
		if (file.files && file.files[0]) {
			var reader = new FileReader();

			reader.onload = function(evt) {
				var filepath = evt.target.result;

				var extStart = filepath.lastIndexOf(".");
				var ext = filepath.substring(extStart, filepath.length)
						.toUpperCase();
				////BMP、JPG、JPEG、PNG、GIF
				//if (ext != ".PNG" && ext != ".BMP" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
				//    //提示信息
				//    alert(" 图片格式不正确！");
				//    return false;
				//}
				$("#img").attr("src", evt.target.result);
			}
			reader.readAsDataURL(file.files[0]);
		} else {
			//prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
			alert($("#img").attr("src"));
			$("#img").attr("src", file.value);
			alert($("#img").attr("src"));
		}
	}
</script>
</head>
<body>
	<form id="form1" action="/infomation/edit" method="post"
		enctype="multipart/form-data">
		<div>
			<%
				InfomationEntity entity = (InfomationEntity) request.getAttribute("entitys");
			%>
			<table
				style="text-align: center; vertical-align: middle; line-height: 50px; margin-left: 20px; margin-top: 20px;">
				<input type="hidden" id="id" name="id" value="<%=entity.getId() == null ? 0:entity.getId()%>" />
				<tr>
					<td class="td_right">标题：</td>
					<td><input type="text" id="title" name="title"
						style="width: 500px;" class="search_txt"
						value="<%=entity.getTitle() == null ? "" : entity.getTitle()%>" /></td>
				</tr>
				<tr>
					<td class="td_right">图片：</td>
					<td><img id="img" style="width: 200px; height: 200px;"
						src="<%=entity.getImg()%>" onclick="upload()" /> <input
						type="file" name="tupian" id="PicLoad" style="display: none;"
						onchange="change(this)"> <input type="text" id="tupian"
						name="tupian" style="display: none;"
						value="<%=entity.getImg() == null ? "" : entity.getImg()%>" />
					</td>
				</tr>
				<tr>
					<td class="td_right">简介：</td>
					<td><textarea style="width: 500px; height: 100px;"
							id="jianjie" name="jianjie" class="search_txt"><%=entity.getInfo() == null ? "" : entity.getInfo()%></textarea>
					</td>
				</tr>
				<tr>
					<td class="td_right">内容：</td>
					<td><textarea style="width: 500px; height: 300px;"
							id="neirong" name="neirong" class="search_txt"><%=entity.getContent() == null ? "" : entity.getContent()%></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" id="btnOK" value="保存"
						class="btn_css submitbg" /> <input type="button" id="btnCZ"
						value="关闭" onclick="window.parent.closedialog();"
						class="btn_css reserbg" style="margin-left: 20px;" /></td>
				</tr>
			</table>
		</div>
	</form>
</body>
</html>
